package com.uit.gis.ui;
import java.awt.Component; 
import javax.swing.JOptionPane; 
import com.uit.gis.util.Language;
import com.uit.gis.util.Util.MessageBox;
import com.uit.gis.util.Util.MessageBoxIcon;
 
 
public class MessageBoxDialog {

    /* 
    These are a list of STATIC MODAL dialogs

    int return codes of button pressed:

        -1 - WINDOW CLOSED - the X PRESSED
         0 - YES and OK
         1 - NO
         2 - CANCEL

    (thanks to flipside for the idea)
     */
 
    public static int Show(String stdmsg)
    {
    	 int result = JOptionPane.showConfirmDialog((Component)
                 null, stdmsg, Language.APP_NAME, JOptionPane.DEFAULT_OPTION);
         return result;
    }
   // public static int Show(String stdmsg, MESSAGEBOX msg)
   // {
    	//return Show( stdmsg, const_string.SOFTWARE_NAME, msg); 
    //}
    public static int Show(String stdmsg, String title, MessageBox msg, MessageBoxIcon icon)
    {
    	int msgOption = JOptionPane.DEFAULT_OPTION;
    	int msgicon = JOptionPane.INFORMATION_MESSAGE;
    	Object options[];
    	switch( msg)
    	{
    	 case OK:
    		 options = new Object[1];
    		 options[0] = "    OK    ";
    		 break;
    	 case OKCANCEL:
    		 options = new Object[2];
    		 options[0] = "  OK  ";
    		 options[1] = "  Cancel  ";
    		 break;
    	 case YESNO:
    		 options = new Object[2];
    		 options[0] = "   Yes   ";
    		 options[1] = "   No   ";
    		 break;
    	 case YESNOCANCEL: 
    		 options = new Object[3];
    		 options[0] = "   Yes   ";
    		 options[1] = "   No   ";
    		 options[2] ="  Cancel  ";
    		break;
    	 case ABORTRETRYIGNORE:
    		 options = new Object[3];
    		 options[0] = "  Abort  ";
    		 options[1] = "  Retry  ";
    		 options[2] ="  Ignore  ";
    		break; 
    		default:
    			 options = new Object[1];
        		 options[0] = "OK";
    			break;
    	}
    	
        switch (icon)
        {
        case INFORMATION:
        	msgicon = JOptionPane.INFORMATION_MESSAGE;
        	break;
        case ERROR:
        	msgicon = JOptionPane.ERROR_MESSAGE;
        	break;
        case QUESTION:
        	msgicon = JOptionPane.QUESTION_MESSAGE;
        	break;
        case WARNNING:
        	msgicon = JOptionPane.WARNING_MESSAGE;
        	break;
        }
    
     int result = JOptionPane.showOptionDialog((Component)null, stdmsg, title, msgOption, msgicon, null, options, options[0]);
  //    System.out.print(result);   
     return result;
    }
     
}